<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">
<h:head>
    <title>Admins</title>
    <f:metadata>
        <f:event listener="#{loginBean.verifySuperadminLogin}" type="preRenderView" update="growl">
        </f:event>
    </f:metadata>
</h:head>
<h:body>
    <ui:composition template="menutemp.xhtml">
        <p:growl id="growl" showDetail="true" autoUpdate="true" life="5000" />
        <h:form id="data">
            <p:toolbar>
                <p:toolbarGroup align="left">
                    <p:commandButton type="button" value="Neu" icon="ui-icon-document" onclick="dlg.show()" />
                    <p:menuButton value="Delete" icon="ui-icon-trash">
                        <p:menuitem id="deleteAll" value="All" actionListener="#{adminBean.deleteAll}"
                            icon="ui-icon-trash" update="data" />
                        <p:menuitem id="deleteSelected" value="Selected" actionListener="#{adminBean.deleteSelected}"
                            icon="ui-icon-trash" update="data" />
                    </p:menuButton>
                </p:toolbarGroup>
            </p:toolbar>
            <p:dataTable id="dataTable" var="admin" value="#{adminBean.admins}" rowKey="#{admin.id}"
                selection="#{adminBean.selectedAdmins}" selectionMode="multiple">
                <f:facet name="header">  
                    Admins 
                </f:facet>
                <p:column sortBy="#{admin.vorname}">
                    <f:facet name="header">
                        <h:outputText value="Vorname" />
                    </f:facet>
                    <h:outputText value="#{admin.vorname}" />
                </p:column>
                <p:column sortBy="#{admin.nachname}">
                    <f:facet name="header">
                        <h:outputText value="Nachname" />
                    </f:facet>
                    <h:outputText value="#{admin.nachname}" />
                </p:column>
                <p:column sortBy="#{admin.eMail}">
                    <f:facet name="header">
                        <h:outputText value="E-Mail" />
                    </f:facet>
                    <h:outputText value="#{admin.eMail}" />
                </p:column>
                <p:column sortBy="#{admin.password}">
                    <f:facet name="header">
                        <h:outputText value="Password" />
                    </f:facet>
                    <h:outputText value="#{admin.password}" />
                </p:column>
                <p:column sortBy="#{admin.istSuperadmin}">
                    <f:facet name="header">
                        <h:outputText value="Superadmin" />
                    </f:facet>
                    <h:outputText value="#{admin.superadmin}" />
                </p:column>
            </p:dataTable>
            <p:dialog header="Admin Daten eingeben" widgetVar="dlg" resizable="false" width="450">
                <h:panelGrid columns="2" style="margin-bottom:10px">

                    <h:outputLabel for="firstname" value="Vorname:" />
                    <p:inputText id="firstname" value="#{adminBean.newVorname}" size="35" />

                    <h:outputLabel for="nachname" value="Nachname:" />
                    <p:inputText id="nachname" value="#{adminBean.newNachname}" size="35" />

                    <h:outputLabel for="eMail" value="E-Mail:" />
                    <p:inputText id="eMail" value="#{adminBean.newEMail}" size="35" />

                    <h:outputLabel for="password" value="Password:" />
                    <p:inputText id="password" value="#{adminBean.newPassword}" size="35" />

                    <h:outputLabel for="superadmin" value="Superadmin?" />
                    <p:inputText id="superadmin" value="#{adminBean.superadmin}" size="35" />
                </h:panelGrid>
                <p:commandButton id="submitButton" value="Submit" actionListener="#{adminBean.submit}" update="data"
                    oncomplete="dlg.hide();" />
            </p:dialog>
        </h:form>

    </ui:composition>


</h:body>
</html>